home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 142 / Gekkan Dennou Club - 2000.3 Vol. 142 (Japan).7z / Gekkan Dennou Club - 2000.3 Vol. 142 (Japan) (Track 1).bin / tools / s_tool / move.c < prev    next >
Text File  |  1999-06-08  |  11KB  |  567 lines

  1. #include    "JX250.H"
  2. #include    <sys\iocs.h>
  3. #include    <sys\dos.h>
  4. #include    <sys\scsi.h>
  5. #include    <stdio.h>
  6. #include    <stdlib.h>
  7.  
  8. //---- 上の群
  9. static    UNchar    b1[9*8]=
  10.         "11ab 22cd"
  11.         "         "
  12.         "33ef 44gh"
  13.         "         "
  14.         "55 66ij A"
  15.         "   77kl B"
  16.         "DD 88mn C"
  17.         "EE 99op  ";
  18. //---- 左下の群
  19. static    UNchar    b2[17]="12 934      56 78";
  20. //---- 右下の群
  21. static    UNchar    b3[8*16]=
  22.         "11abAAAA"
  23.         "        "
  24.         "22cdBBBB"
  25.         "33efCCCC"
  26.         "44ghDDDD"
  27.         "        "
  28.         "55ijEEEE"
  29.         "66klFFFF"
  30.         "77mnGGGG"
  31.         "  opHHHH"
  32.         "        "
  33.         "88qrIIII"
  34.         "99stJJJJ"
  35.         "00uvKKKK"
  36.         "        "
  37.         "WWXXYYZZ";
  38.  
  39. UNchar    msp[17]={
  40.         1,        // 標準
  41.         6,2,3,4,3,5,0,0,
  42.         2,0,5,0,4,0,0,0
  43. };
  44. //char    msps[6]={0,0,-8,-8,-8,-8};
  45.  
  46. /**********************************************************
  47.         メインループ
  48. **********************************************************/
  49. int    move()
  50. {
  51. int    i,r,f;
  52. int    x,y,xx,yy,xo,yo,b;
  53. MAP=MapAdds;
  54. for(;;){
  55.     xo=-1;
  56.     yo=-1;
  57.     do {
  58.         _dos_keysns();
  59.         _dos_change_pr();
  60.         yy=( i=_ms_curgt_() )&0xFFFF;
  61.         xx=i>>16;
  62.         if ( xo!=xx || yo!=yy ){
  63.             f=fream_mousepos(xx,yy);
  64.             MsPat(msp[f+1]);
  65.             xo=xx;
  66.             yo=yy;
  67.         }
  68.     } while( MS_LSW()==0 && (b=MS_RSW())==0 );
  69.     if ( b!=0 ){
  70.         //右クリック
  71.         if ( xx>=2*8-2 && xx<31*8+2 && yy>=2*8-2 && yy<62*8+2 )
  72.             r=click_bar(xx,yy);
  73.     } elif ( f>=0 ){
  74.         // 枠内だ
  75.         if ( (_iocs_bitsns(0xE)&bit(0))==0 ){
  76.             move_fream(xx,yy,f);
  77.         } else {
  78.             MsPat(1);
  79.             new_fream(xx,yy);
  80.         }
  81.     } elif ( xx>=2*8-2 && xx<31*8+2 && yy>=2*8-2 && yy<62*8+2 ){
  82.         // 枠スキャン画面内だ
  83.         new_fream(xx,yy);
  84.     } else {
  85.         x=xx/16;
  86.         y=yy/16;
  87.         r=0;
  88.         if ( x>=17 && x<26 && y>=2 && y<10 ){
  89.             //--- 上のボックス
  90.             i=b1[(x-17)+(y-2)*9];
  91.             if ( i==' ' )
  92.                 continue;
  93.             r=click_botton1( i,xx,yy );
  94.         } elif ( (x==17||x==18) && (y>=14 && y<=30) ){
  95.             //--- 左のボックス
  96.             i=b2[y-14];
  97.             if ( i==' ' )
  98.                 continue;
  99.             r=click_botton2( i,xx,yy );
  100.         } elif ( x>=23 && x<31 && y>=15 && y<31 ){
  101.             //--- 右のボックス
  102.             i=b3[(x-23)+(y-15)*8];
  103.             if ( i==' ' )
  104.                 continue;
  105.             r=click_botton3( i,xx,yy );
  106.         } elif ( xx>=33*8 && xx<47*8 && yy>=22*8 && yy<26*8 ){
  107.             //--- プリスキャン
  108.             if ( sxbotton(33*8,22*8,47*8,26*8,1)==0 ){
  109.                 MsPat(-1);
  110.                 SCSI_ID=AutoSreachJX(SCSI_ID,-1);
  111.                 if ( SCSI_ID>=0 && SCSI_ID<=15 )
  112.                     PreScanDisp();
  113.             }
  114.         } elif ( xx>=49*8 && xx<63*8 && yy>=22*8 && yy<26*8 ){
  115.             //--- スキャン
  116.             if ( sxbotton(49*8,22*8,63*8,26*8,1)==0 ){
  117.                 MsPat(-1);
  118.                 SCSI_ID=AutoSreachJX(SCSI_ID,-1);
  119.                 if ( SCSI_ID>=0 && SCSI_ID<=15 )
  120.                     ScanDisp();
  121.             }
  122.         } elif ( (x==13 || x==14) && y==0 ){
  123.             //---表示倍率
  124.             r=click_botton4(x);
  125.         } elif ( x>=27 && x<=30 && y>=6 && y<=9 ){
  126.             //--- 青スイッチ群
  127.             r=click_botton5((x-27)/2,(y-6)/2);
  128.         } elif ( x==0 && ( y==1 || y==30 ) ){
  129.             //--- 縦バー(ボタン)
  130.             r=click_botton6(y,0);
  131.         } elif ( xx>=6 && xx<=9 && yy>=32 && yy<480 ){
  132.             //--- 縦バー
  133.             r=click_botton6(yy,1);
  134.         } elif ( y==31 && ( x==1 || x==15 ) ){
  135.             //--- 横バーボタン
  136.             r=click_botton7(x,0);
  137.         } elif ( yy>=501 && yy<=506 && xx>=32 && xx<15*16 ){
  138.             //--- 縦バー
  139.             r=click_botton7(xx,1);
  140.         }
  141.         if ( r==99 && mv_eq() )
  142.             break;
  143.     }
  144.     while( MS_LSW()!=0 || MS_RSW()!=0 ){
  145.         yy=( i=_ms_curgt_() )&0xFFFF;
  146.         xx=i>>16;
  147.         if ( xo!=xx || yo!=yy ){
  148.             f=fream_mousepos(xx,yy);
  149.             MsPat(msp[f+1]);
  150.             xo=xx;
  151.             yo=yy;
  152.         }
  153.         _dos_keysns();
  154.         _dos_change_pr();
  155.     }
  156. }
  157. return(r);
  158. }
  159. /*+++++++++++*/
  160. int    mv_eq()
  161. {
  162. PosDedraw();
  163. if ( Dialog("","終了しますか?","",2) ){
  164.     while( MS_LSW()!=0 || MS_RSW()!=0 );
  165.     PosSetDraw(PreX1,PreY1,PreX2,PreY2,-1);
  166.     return(0);
  167. }
  168. return(-1);
  169. }
  170. /**********************************************************
  171.         枠移動
  172. **********************************************************/
  173. void    move_fream(sx,sy,fm)
  174. int    sx,sy,fm;
  175. {
  176. int    i,x,y,xo,yo,bi,rs;
  177. int    xx,yy,b;
  178. int    x1o,y1o,x2o,y2o;
  179. int    x1,x2,y1,y2;
  180. int    _PreX1,_PreY1;
  181. int    _PreX2,_PreY2;
  182. //--- 記憶
  183. _PreX1 = PreX1;
  184. _PreY1 = PreY1;
  185. _PreX2 = PreX2;
  186. _PreY2 = PreY2;
  187. x1o=y1o=-1;
  188. xo=-1;
  189. yo=-1;
  190. bi=1<<PreBai;
  191. while( MS_LSW()!=0 && (b=MS_RSW())==0 ){
  192.     _dos_keysns();
  193.     _dos_change_pr();
  194.     yy=( i=_ms_curgt_() )&0xFFFF;
  195.     xx=i>>16;
  196.     if ( xo==xx && yo==yy )
  197.         continue;
  198.     xo=xx;
  199.     yo=yy;
  200.     rs=0;
  201.     if ( PreBai!=0 ){
  202.         int    _x,_y;
  203.         _x=PrePX;
  204.         _y=PrePY;
  205.         if ( xx<16 ){
  206.             if ( PrePX>0 ){
  207.                 PrePX-=16/bi;
  208.                 if ( PrePX<0 )
  209.                     PrePX=0;
  210.             }
  211.         }
  212.         if ( yy<16-3 ){
  213.             if ( PrePY>0 ){
  214.                 PrePY-=16/bi;
  215.                 if ( PrePY<0 )
  216.                     PrePY=0;
  217.             }
  218.         }
  219.         if ( xx>232+16 ){
  220.             if ( PrePX<=(232-(232/bi)) ){
  221.                 PrePX+=16/bi;
  222.                 if ( PrePX>=(232-(232/bi)) )
  223.                     PrePX=(232-(232/bi))-1+1;
  224.             }
  225.         }
  226.         if ( yy>496+3 ){
  227.             if ( PrePY<=(480-(480/bi)) ){
  228.                 PrePY+=16/bi;
  229.                 if ( PrePY>=(480-(480/bi)) )
  230.                     PrePY=(480-(480/bi))-1+1;
  231.             }
  232.         }
  233.         if ( _x!=PrePX || _y!=PrePY ){
  234.             sx+=(_x-PrePX)*bi;
  235.             sy+=(_y-PrePY)*bi;
  236.             xx+=(_x-PrePX)*bi;
  237.             yy+=(_y-PrePY)*bi;
  238.             _iocs_ms_curst(xx,yy);
  239.             PosDedraw();
  240.             PreviewView();
  241.             rs=1;
  242.         }
  243.     }
  244.     if ( PreBai==0 ){
  245.         x=(xx-sx)*10224/232;
  246.         y=(yy-sy)*14064/480;
  247.     } else {
  248.         i=1<<PreBai;
  249.         //x=((xx-sx)*10224/232)/i;
  250.         //y=((yy-sy)*14064/480)/i;
  251.         x=(xx*10224/232/i)-(sx*10224/232/i);
  252.         y=(yy*14064/480/i)-(sy*14064/480/i);
  253.     }
  254.     x1 = _PreX1;
  255.     y1 = _PreY1;
  256.     x2 = _PreX2;
  257.     y2 = _PreY2;
  258.     if ( fm==0 ){
  259.         //--- 全体ムーブ
  260.         //
  261.         if ( x<0 ){
  262.             if ( x1+x>=0 ){
  263.                 x1 += x;
  264.                 x2 += x;
  265.             } else {
  266.                 x2 -= x1;
  267.                 x1 -= x1;
  268.             }
  269.         } elif ( x>0 ){
  270.             if ( x2+x<=10224-1 ){
  271.                 x1 += x;
  272.                 x2 += x;
  273.             } else {
  274.                 x1 += (10224-1)-x2;
  275.                 x2 += (10224-1)-x2;
  276.             }
  277.         }
  278.         if ( y<0 ){
  279.             if ( y1+y>=0 ){
  280.                 y1 += y;
  281.                 y2 += y;
  282.             } else {
  283.                 y2 -= y1;
  284.                 y1 -= y1;
  285.             }
  286.         } elif ( y>0 ){
  287.             if ( y2+y<=14064-1 ){
  288.                 y1 += y;
  289.                 y2 += y;
  290.             } else {
  291.                 y1 += (14064-1)-y2;
  292.                 y2 += (14064-1)-y2;
  293.             }
  294.         }
  295.     } else {
  296.         // bit 0 ; 上    bit 1 ; 左
  297.         // bit 2 ; 右    bit 3 ; 下
  298.         if ( (fm&bit(0))!=0 ){
  299.             //上
  300.             if ( y<0 ){
  301.                 if ( y1+y>=0 )
  302.                     y1 += y;
  303.                 else    y1 = 0;
  304.             } else {
  305.                 if ( y1+y<=(y2-16) )
  306.                     y1 += y;
  307.                 else    y1 = (y2-16);
  308.             }
  309.         }
  310.         if ( (fm&bit(1))!=0 ){
  311.             //左
  312.             if ( x<0 ){
  313.                 if ( x1+x>=0 )
  314.                     x1 += x;
  315.                 else    x1 = 0;
  316.             } else {
  317.                 if ( x1+x<=(x2-16) )
  318.                     x1 += x;
  319.                 else    x1 = (x2-16);
  320.             }
  321.         }
  322.         if ( (fm&bit(2))!=0 ){
  323.             //右
  324.             if ( x<0 ){
  325.                 if ( x2+x>=(x1+16) )
  326.                     x2 += x;
  327.                 else    x2 = (x1+16);
  328.             } else {
  329.                 if ( x2+x<=10224-1 )
  330.                     x2 += x;
  331.                 else    x2 = (10224-1);
  332.             }
  333.         }
  334.         if ( (fm&bit(3))!=0 ){
  335.             //下
  336.             if ( y<0 ){
  337.                 if ( y2+y>=(y1+16) )
  338.                     y2 += y;
  339.                 else    y2 = (y1+16);
  340.             } else {
  341.                 if ( y2+y<=14064-1 )
  342.                     y2 += y;
  343.                 else    y2 = (14064-1);
  344.             }
  345.         }
  346.     }
  347.     if ( x1!=x1o || y1!=y1o || x2!=x2o || y2!=y2o ){
  348.         PosSetDraw(x1,y1,x2,y2,-1);
  349.         x1o=x1;
  350.         y1o=y1;
  351.         x2o=x2;
  352.         y2o=y2;
  353.     } elif ( rs!=0 ){
  354.         PosSetDraw(x1,y1,x2,y2,-1);
  355.     }
  356.     CalcScanPara();
  357. }
  358. if ( b!=0 ){
  359.     //右クリック キャンセル
  360.     PosSetDraw(_PreX1,_PreY1,_PreX2,_PreY2,-1);
  361.     MsPat(-1);
  362.     CalcScanPara();
  363.     while( MS_LSW()!=0 || MS_RSW()!=0 );
  364.     return;
  365. }
  366. return;
  367. }
  368. /**********************************************************
  369.         枠新規
  370. **********************************************************/
  371. void    new_fream(sx,sy)
  372. int    sx,sy;
  373. {
  374. int    i,m,n,x,y,xo,yo;
  375. int    xx,yy,b;
  376. int    x1o,y1o;
  377. int    px1,py1,px2,py2;
  378. int    _PreX1,_PreY1;
  379. int    _PreX2,_PreY2;
  380. //--- 記憶
  381. _PreX1 = PreX1;
  382. _PreY1 = PreY1;
  383. _PreX2 = PreX2;
  384. _PreY2 = PreY2;
  385. x1o=y1o=-1;
  386. xo=-1;
  387. yo=-1;
  388. //--- はじめの位置を記憶
  389. if ( PreBai==0 ){
  390.     px1=(sx-16)*10224/232;
  391.     py1=(sy-16)*14064/480;
  392. } else {
  393.     i=1<<PreBai;
  394.     px1=((sx-16+PrePX*i)*10224/232)/i;
  395.     py1=((sy-16+PrePY*i)*14064/480)/i;
  396. }
  397. px2=px1+1;
  398. py2=py1+1;
  399. PosSetDraw(px1,py1,px2,py2,-1);
  400. CalcScanPara();
  401. while( MS_LSW()!=0 && (b=MS_RSW())==0 ){
  402.     _dos_keysns();
  403.     _dos_change_pr();
  404.     yy=( i=_ms_curgt_() )&0xFFFF;
  405.     xx=i>>16;
  406.     if ( xo==xx && yo==yy )
  407.         continue;
  408.     xo=xx;
  409.     yo=yy;
  410.     if ( PreBai==0 ){
  411.         x=(xx-16)*10224/232;
  412.         y=(yy-16)*14064/480;
  413.     } else {
  414.         i=1<<PreBai;
  415.         x=((xx-16+PrePX*i)*10224/232)/i;
  416.         y=((yy-16+PrePY*i)*14064/480)/i;
  417.     }
  418.     m=px1;
  419.     n=py1;
  420.     if ( x>m ){
  421.         m=x;
  422.         x=px1;
  423.     }
  424.     if ( y>n ){
  425.         n=y;
  426.         y=py1;
  427.     }
  428.     if ( x<0 )
  429.         x=0;
  430.     if ( m>10224-1 )
  431.         m=10224-1;
  432.     if ( y<0 )
  433.         y=0;
  434.     if ( n>14064-1 )
  435.         n=14064-1;
  436.     PosSetDraw(x,y,m,n,-1);
  437.     CalcScanPara();
  438. }
  439. if ( b!=0 || (PreX2==PreX1+1 && PreY2==PreY1+1) ){
  440.     //右クリック キャンセル
  441.     PosSetDraw(_PreX1,_PreY1,_PreX2,_PreY2,-1);
  442.     CalcScanPara();
  443.     MsPat(-1);
  444.     while( MS_LSW()!=0 || MS_RSW()!=0 );
  445.     return;
  446. }
  447. return;
  448. }
  449. /********************************************************
  450.     青スイッチ群
  451. ********************************************************/
  452. int    click_botton5(xx,yy)
  453. int    xx,yy;
  454. {
  455. int    r;
  456. if ( sxbotton(27*16+xx*32+1,6*16+yy*32+1,27*16+xx*32+30,6*16+yy*32+30,1)!=0 )
  457.     return(0);
  458. if ( xx==1 && yy==1 ){
  459.     //--- 終了
  460.     return(99);
  461. }
  462. if ( xx==0 && yy==1 ){
  463.     EnvMode();
  464.     return(0);
  465. }
  466. if ( xx==1 && yy==0 ){
  467.     //--- 記録
  468.     r=RecodeMode();
  469.     return(r);
  470. }
  471. if ( xx==0 && yy==0 ){
  472.     //---- 画像
  473.     ViewMode();
  474.     return(0);
  475. }
  476. return(0);
  477. }
  478. /********************************************************
  479.         プリスキャン
  480. ********************************************************/
  481. void    PreScanDisp()
  482. {
  483. PosDedraw();
  484. Dialog(0,0,"  プリスキャン中",0);
  485. Scan(0,SCSI_ID);    // Prescan!!
  486. PosSetDraw(PreX1,PreY1,PreX2,PreY2,-1);
  487. PreviewView();
  488. }
  489. /********************************************************
  490.         スキャンするぞー
  491. ********************************************************/
  492. void    ScanDisp()
  493. {
  494. int    i,j;
  495. //--- データ用のメモリ確保
  496. if ( (int)ScanData>99 ){
  497.     _dos_mfree(ScanData);
  498.     ScanData=0;
  499. }
  500. TXCLS(0);            //TEXT クリア
  501. AspScreen();
  502. _iocs_g_clr_on();
  503. Dialog(0,0,"   スキャン中",0);
  504. //---
  505. i=Scan(1,SCSI_ID);    // Scan!!
  506. if ( i==0 ){
  507.     //---------------- 成功
  508.     //----- 画面(512x512) に入る倍率を捜す
  509.     for(j=2;j>=-1;j--){
  510.         if ( (ScanDataX*(1<<(j+3))/8)<=512 && (ScanDataY*(1<<(j+3))/8)<=512 )
  511.             break;
  512.     }
  513.     RecVwBai=j;        // 0;x1  1;x2  2;x4 3;x8
  514.                 //-1;/2 -2;/4 -3;/8
  515.     VewPX=0;
  516.     VewPY=0;
  517.     _iocs_g_clr_on();
  518.     _iocs_home(0,0,0);
  519.     if ( SaveFrmMode==0 ){    // 0;スキャンサイズに変更
  520.         RecX2=0;
  521.         RecY2=0;    // これでスキャンのサイズになる
  522.     }
  523.     ViewMode();
  524.     return;
  525. } else {
  526.     //---------------- だめでした
  527.     _iocs_home(0,0,0);
  528.     if ( (int)ScanData>99 ){
  529.         _dos_mfree(ScanData);
  530.         ScanData=0;
  531.     }
  532.     if ( i==-1 ){
  533.         Dialog(0,"エラーが出てしまいました",0,1);
  534.     } elif ( i==-2 ){
  535.         Dialog(    0,
  536.             "SCSI エラーが出ました",
  537.             "スキャナを確認して下さい",
  538.             1
  539.         );
  540.     } elif ( i==-3 ){
  541.         Dialog(    "パラメータに問題があります",
  542.             "取り込みサイズを確認して下",
  543.             "さい",
  544.             1
  545.         );
  546.     } elif ( i==-4 ){
  547.         Dialog(    "メモリが足りません",
  548.             "取り込みサイズを小さくして",
  549.             "下さい",
  550.             1
  551.         );
  552.     } elif ( i==-9 ){
  553.         Dialog(    "",
  554.             "  中断しました",
  555.             "",
  556.             1
  557.         );
  558.     }
  559. }
  560. //-- 画面をもとに
  561. _iocs_crtmod(0x100+12);
  562. ViewScrren();
  563. PreviewView();
  564. return;
  565. }
  566.  
  567.